<%-- 
    Document   : viewtickets
    Created on : Nov 23, 2009, 8:27:00 PM
    Author     : brian
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.util.ArrayList, helpdesk.HelpTicket" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<%!
    ArrayList<HelpTicket> tickets;
    String err;
%>

<%
    tickets = (ArrayList<HelpTicket>)request.getAttribute("tickets");
    err = (String)request.getAttribute("error");
    if (err == null)
        err = "";
%>

<html>
    <head>
        <%@include file="headtags.html"%>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Tickets</title>
    </head>
    <body>
        <%@include file="menu.html"%>
        <%= err %>
        <table class="content" width ="100%"><tr class="heading"><td align="center">Tickets</td></tr><tr><td>
        <table class="ticket">
            <tr>
                <th class="ticket">ID</th>
                <th class="ticket">Created by</th>
                <th class="ticket">Area</th>
                <th class="ticket">Priority</th>
                <th class="ticket">Title</th>
                <th class="ticket">Assigned to</th>
                <th class="ticket">Created on</th>
                <th class="ticket">Last Updated</th>
                <th class="ticket">Status</th>
            </tr>
            <%
                if (tickets != null)
                {
                for (int i=0;i<tickets.size();i++)
                    {
                        HelpTicket t = tickets.get(i);
                        %>
                        <tr>
                            <td class="ticket"><a href="ticketdetails.jsp?ticketid=<%=t.getId()%>"><%=t.getId()%></a></td>
                            <td class="ticket"><a href="viewprofile.jsp?userid=<%=t.getUserId()%>"><%= t.getUser() %></a></td>
                            <td class="ticket"><%= t.getExpertise() %></td>
                            <td class="ticket"><%= t.getPriority() %></td>
                            <td class="ticket"><a href="ticketdetails.jsp?ticketid=<%=t.getId()%>"><%= t.getTitle() %></a></td>
                            <td class="ticket"><%= t.getSupportUser() != null
                                ? "<a href=\"viewprofile.jsp?userid=" + t.getSupportUserId() + "\">" + t.getSupportUser() + "</a>"
                                : "Unassigned" %></td>
                            <td class="ticket"><%= t.getDateOpened() %></td>
                            <td class="ticket"><%= t.getModified() %></td>
                            <td class="ticket"><%= t.getDateClosed() != null ? "Closed on " + t.getDateClosed() : "Open" %></td>
                        </tr>
                        <%
                    }
                }
            %>
        </table>
        </td></tr></table>
    </body>
</html>
